package com.seu.me.disruptor.generate1;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

import java.util.UUID;

/**
 * Created by liangfeihu on 2017/11/26.
 */
public class TradeHandler implements EventHandler<Trade>, WorkHandler<Trade> {

    @Override
    public void onEvent(Trade event, long sequence, boolean endOfBatch) throws Exception {
        this.onEvent(event);
    }

    @Override
    public void onEvent(Trade event) throws Exception {
        //这里做具体的消费逻辑
        //简单生成下ID
        event.setId(UUID.randomUUID().toString().replace("-", ""));
        System.out.println("id=" + event.getId() + ", price=" + event.getPrice());
    }
}  